package com.yjm.test.Spring5.ch4.factoryBean;

import java.security.MessageDigest;

import org.springframework.beans.factory.FactoryBean;
import org.springframework.beans.factory.InitializingBean;

public class MessageDigestFactoryBean implements FactoryBean<MessageDigest>, InitializingBean {
	private String algorithmName = "MD5";
	public String getAlgorithmName() {
		return algorithmName;
	}
	public void setAlgorithmName(String algorithmName) {
		this.algorithmName = algorithmName;
	}
	private MessageDigest messageDigest;
	@Override
	public void afterPropertiesSet() throws Exception {
		// TODO Auto-generated method stub
		messageDigest = MessageDigest.getInstance(algorithmName);
	}
	@Override
	public MessageDigest getObject() throws Exception {
		// TODO Auto-generated method stub
		return messageDigest;
	}
	@Override
	public Class<?> getObjectType() {
		// TODO Auto-generated method stub
		return MessageDigest.class;
	}

}
